<?php

class Admin_Controllers_Category extends Libs_Controller {

    function __construct() {
        parent::__construct();
    }

    public function index() {
        $this->view->render('category/index');
    }

    public function addCat() {
        $c = new Admin_Models_Category();

        $c->setName($_POST['txtName']);
        $c->setParentId($_POST['sltParentId']);

        $c->insertCat($c);

        header("Location: " . URL_BASE . "/admin/category");
    }

    public function editCat() {
        $c = new Admin_Models_Category();
        $cat_id = $_POST['cat_id'];
        $c->setName($_POST['txtName']);
        $c->setParentId($_POST['sltParentId']);

        $c->updateCat($c, $cat_id);

        header("Location: " . URL_BASE . "/admin/category");
    }

    public function delCat($cat_id) {
        $cat = new Admin_Models_Category();
        $cat->deleteCat($cat_id);

        header("Location: " . URL_BASE . "/admin/category");
    }

}
